package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
        Collection<String> c=new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");

        Iterator<String> it=c.iterator();
        while (it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }


        for(String str:c){
            System.out.println(str);
        }



        Collection<Point> cc= new ArrayList<>();
        cc.add(new Point(1,2));
        cc.add(new Point(3,4));
        cc.add(new Point(5,6));
        cc.add(new Point(7,8));


        Iterator<Point> it1=cc.iterator();
        while (it1.hasNext()){
            Point p=it1.next();
            System.out.println(p);
        }


        for (Point p:cc){
            System.out.println(p);
        }








    }


}
